#include "custem_msg.hpp"

custem_msg::custem_msg(string name):
    rclcpp::Node(name)
{
    RCLCPP_INFO(this->get_logger(),"create node name : %s",name.c_str());
    pub = this->create_publisher<tin::msg::Tin>("tin_topic",10);
    sub = this->create_subscription<tin::msg::Tin>("tin_topic",10,
                                                   std::bind(&custem_msg::sub_callback,this,std::placeholders::_1));
    timer_ = this->create_wall_timer(std::chrono::milliseconds(100),std::bind(&custem_msg::timer_callback,this));
}

void custem_msg::timer_callback()
{
    static tin::msg::Tin msg;
    msg.angle = 3.1415926*msg.count;
    msg.count++;
    msg.row = msg.count+msg.row;
    msg.text = "Tin-test";
    pub->publish(msg);
}

void custem_msg::sub_callback(tin::msg::Tin msg)
{
    RCLCPP_INFO(this->get_logger(),"msg.angle:%f,msg.colon:%d,msg.count:%d,msg.row:%d,msg.text:%s",
                                   msg.angle,msg.colon,msg.count,msg.row,msg.text.c_str());
}
